//
//  FontExtension.swift
//  NeighboryCountryDong
//
//  Created by youwei on 2024/12/18.
//

import SwiftUI

extension Font {
    enum InterWeight: CaseIterable {
        case regular
        case extraBold
        case semiBold
        case medium
    }
    
    static func inter(size: CGFloat, weight: InterWeight? = nil) -> Font {
        
        switch weight {
        case .regular, nil:
            return .custom("Inter-Regular", size: size)
        case .extraBold:
            return .custom("Inter-ExtraBold", size: size)
        case .semiBold:
            return .custom("Inter-SemiBold", size: size)
        case .medium:
            return .custom("Inter-Medium", size: size)
        }
    }
    
    enum AlibabaPuHuiTiWeight: CaseIterable {
        case regular
        case medium
        case semiBold
        
    }
    
    static func alibabaPuHuiTi(size: CGFloat, weight: AlibabaPuHuiTiWeight) -> Font {
        switch weight {
        case .regular:
            return .custom("AlibabaPuHuiTi_2_55_Regular", size: size)
        case .medium:
            return .custom("AlibabaPuHuiTi_2_65_Medium", size: size)
        case .semiBold:
            return .custom("AlibabaPuHuiTi_2_75_SemiBold", size: size)
        }
    }
}

struct FoodTestView: View {
    var a: String {
        for family in UIFont.familyNames {
            print("Family: \(family)")
            for name in UIFont.fontNames(forFamilyName: family) {
                print(" - \(name)")
            }
        }
        return "aa"
    }
    var body: some View {
        VStack {
            Text("汉体\(a)")
                .font(.alibabaPuHuiTi(size: 20.0, weight: .regular))
            Text("汉体")
                .font(.alibabaPuHuiTi(size: 20.0, weight: .medium))
            Text("汉体")
                .font(.alibabaPuHuiTi(size: 20.0, weight: .semiBold))
        }

    }
}

#Preview {
    FoodTestView()
}
